/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jpm.jroguefx.utilities;

import com.jpm.jroguefx.Constants;

import java.util.Random;

public class Utilities implements Constants {

    private final static Random rand = new Random();

    public static boolean roll(final int target, final int total) {
        return (rand.nextInt(total) >= target);
    }

    public static int random(int total) {
        return random0(total) + 1;
    }

    public static int random0(int total) {
        return (int) (Math.random() * total);
    }

    public static int random(int min, int max) {
        return (int) (Math.random() * (max - min + 1)) + min;
    }

    public static int adjust(int target, int var) {
        return (int) ((Math.random() * (var * 2 + 1)) + target - (var / 2));
    }
}
